package com.znsb.msfq.album;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.znsb.msfq.BaseActivity;
import com.znsb.msfq.R;
import com.znsb.msfq.utils.CacheActivityUtils;
import com.znsb.msfq.view.selectorphoto.Bimp;
import com.znsb.msfq.view.selectorphoto.PublicWay;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 这个类主要是用来进行显示包含图片的文件夹
 *
 * @author king
 * @version 2014年10月18日 下午11:48:06
 * @QQ:595163260
 */
public class ImageFileActivity extends BaseActivity {

    @Bind(R.id.bar_img_back)
    ImageView barImgBack;
    @Bind(R.id.bar_tv_title)
    TextView barTvTitle;
    @Bind(R.id.bar_tv_other)
    TextView barTvOther;
    @Bind(R.id.fileGridView)
    GridView fileGridView;
    private FolderAdapter folderAdapter;

    @Override
    protected int getlayoutView() {
        return R.layout.plugin_camera_image_file;
    }

    @Override
    protected void initView(View view) {
        PublicWay.activityList.add(this);
        folderAdapter = new FolderAdapter(this);
        fileGridView.setAdapter(folderAdapter);
        barTvTitle.setText("选择相册");
        barTvOther.setVisibility(View.VISIBLE);
        barTvOther.setText("取消");
    }

    @Override
    protected void initData() {
        barTvOther.setOnClickListener(new CancelListener());
    }

    @Override
    protected void clickListener(View view) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.bar_img_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bar_img_back:
                finish();
                break;
        }
    }

    private class CancelListener implements OnClickListener {// 取消按钮的监听

        public void onClick(View v) {
            // 清空选择的图片
            Bimp.tempSelectBitmap.clear();
            CacheActivityUtils.finishSingleActivityByClass(AlbumActivity.class);
            finish();
        }
    }
}
